<html>
<head><meta charset="utf-8"><title>repr(simd) struct&lt;const N: usize&gt;([T; N]) · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html">repr(simd) struct&lt;const N: usize&gt;([T; N])</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="172513987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172513987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172513987">(Aug 05 2019 at 15:41)</a>:</h4>
<p>I am trying to call Const.unwrap_usize in typeck chec, but am getting:</p>
<div class="codehilite"><pre><span></span>error: internal compiler error: src/librustc/ty/sty.rs:2337: expected constant usize, got Const {
    ty: usize,
    val: Unevaluated(
        DefId(0:15 ~ simd_array_type[317d]::S[0]::0[0]::{{constant}}[0]),
        [],
    ),
}
</pre></div>


<p>IIUC, the ty is correctly an usize, but the value is not an usize, but <code>Unevaluated</code> instead</p>



<a name="172514061"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172514061" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172514061">(Aug 05 2019 at 15:42)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> i'm not sure how to deal with that. Is there a way to evaluate it ?</p>



<a name="172514078"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172514078" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172514078">(Aug 05 2019 at 15:42)</a>:</h4>
<p>In my case, the value can either be a power of two, or a const generic</p>



<a name="172514104"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172514104" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172514104">(Aug 05 2019 at 15:43)</a>:</h4>
<p>you can't eval a const generic</p>



<a name="172514122"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172514122" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172514122">(Aug 05 2019 at 15:43)</a>:</h4>
<p>unless you substitute the const generic, at which point you're not evaluating a const generic</p>



<a name="172514125"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172514125" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172514125">(Aug 05 2019 at 15:43)</a>:</h4>
<p>it currently isn't a const generic though</p>



<a name="172514130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172514130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172514130">(Aug 05 2019 at 15:43)</a>:</h4>
<p>it's generic, you can't know its value</p>



<a name="172514132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172514132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172514132">(Aug 05 2019 at 15:43)</a>:</h4>
<p>hmm</p>



<a name="172514189"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172514189" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172514189">(Aug 05 2019 at 15:44)</a>:</h4>
<p>currently i have an [i32; 4] array</p>



<a name="172514194"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172514194" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172514194">(Aug 05 2019 at 15:44)</a>:</h4>
<p>so you want me to work on <a href="https://github.com/rust-lang/rust/pull/59369" target="_blank" title="https://github.com/rust-lang/rust/pull/59369">https://github.com/rust-lang/rust/pull/59369</a> :D</p>



<a name="172514237"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172514237" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172514237">(Aug 05 2019 at 15:44)</a>:</h4>
<p>:D</p>



<a name="172514252"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172514252" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172514252">(Aug 05 2019 at 15:45)</a>:</h4>
<p>ok, I think I will skip the check for now</p>



<a name="172525506"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172525506" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172525506">(Aug 05 2019 at 18:15)</a>:</h4>
<p>You can also try to subst and normalize first</p>



<a name="172525537"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172525537" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172525537">(Aug 05 2019 at 18:15)</a>:</h4>
<p>It's hacky but should work until my PR is through</p>



<a name="172527133"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172527133" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172527133">(Aug 05 2019 at 18:36)</a>:</h4>
<p>ok, nevermind, got the PR ready and sent it to bors</p>



<a name="172527142"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172527142" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172527142">(Aug 05 2019 at 18:36)</a>:</h4>
<p>you should be able to rebase over it soonish</p>



<a name="172681957"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172681957" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172681957">(Aug 07 2019 at 14:21)</a>:</h4>
<p>thanks <span class="user-mention" data-user-id="124288">@oli</span> , it looks like this landed, i'll try it out</p>



<a name="172681975"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172681975" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172681975">(Aug 07 2019 at 14:21)</a>:</h4>
<p>let me know if anything is off</p>



<a name="172682067"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682067" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682067">(Aug 07 2019 at 14:22)</a>:</h4>
<p>I want to support <code>#[repr(simd)] struct Simd&lt;T, const N: usize&gt;([T; N]);</code></p>



<a name="172682082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682082">(Aug 07 2019 at 14:22)</a>:</h4>
<p>so needed that for a piece in layout where <code>simd_size</code> is called</p>



<a name="172682110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682110">(Aug 07 2019 at 14:23)</a>:</h4>
<p>uh</p>



<a name="172682146"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682146" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682146">(Aug 07 2019 at 14:23)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="go">rg &#39;simd_size\(&#39; src/</span>
<span class="go">src/librustc_codegen_llvm/intrinsic.rs</span>
<span class="go">1095:        let v_len = arg_tys[1].simd_size(tcx);</span>
<span class="go">1110:    let in_len = arg_tys[0].simd_size(tcx);</span>
<span class="go">1125:        let out_len = ret_ty.simd_size(tcx);</span>
<span class="go">1150:        let out_len = ret_ty.simd_size(tcx);</span>
<span class="go">1211:        let v_len = arg_tys[1].simd_size(tcx);</span>
<span class="go">1427:        require!(in_len == arg_tys[1].simd_size(tcx),</span>
<span class="go">1430:                 arg_tys[1].simd_size(tcx));</span>
<span class="go">1431:        require!(in_len == arg_tys[2].simd_size(tcx),</span>
<span class="go">1434:                 arg_tys[2].simd_size(tcx));</span>
<span class="go">1531:        require!(in_len == arg_tys[1].simd_size(tcx),</span>
<span class="go">1534:                 arg_tys[1].simd_size(tcx));</span>
<span class="go">1535:        require!(in_len == arg_tys[2].simd_size(tcx),</span>
<span class="go">1538:                 arg_tys[2].simd_size(tcx));</span>
<span class="go">1758:        let out_len = ret_ty.simd_size(tcx);</span>

<span class="go">src/librustc/ty/sty.rs</span>
<span class="go">1839:    pub fn simd_size(&amp;self, tcx: TyCtxt&lt;&#39;tcx&gt;) -&gt; usize {</span>

<span class="go">src/librustc/ty/layout.rs</span>
<span class="go">697:                let count = ty.simd_size(tcx) as u64;</span>
</pre></div>



<a name="172682213"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682213" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682213">(Aug 07 2019 at 14:24)</a>:</h4>
<p>that's everywhere where it is used - in librustc_codegen_llvm the value of N should be known</p>



<a name="172682249"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682249" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682249">(Aug 07 2019 at 14:25)</a>:</h4>
<p>only in librustc/ty/layout.rs we use it in a place where <code>N</code> maybe isn't known, no idea</p>



<a name="172682260"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682260" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682260">(Aug 07 2019 at 14:25)</a>:</h4>
<p>yes, but you're doing "the wrong thing"^TM if you're using <code>eval_usize</code></p>



<a name="172682274"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682274" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682274">(Aug 07 2019 at 14:25)</a>:</h4>
<p>you should not touch <code>librustc/ty/layout</code></p>



<a name="172682277"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682277" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682277">(Aug 07 2019 at 14:25)</a>:</h4>
<p>sorry I should have asked what you are trying to solve</p>



<a name="172682295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682295">(Aug 07 2019 at 14:25)</a>:</h4>
<p>i'm only touching <code>librustc/ty/sty.rs</code> which is where <code>simd_size</code> is implemented</p>



<a name="172682361"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682361" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682361">(Aug 07 2019 at 14:26)</a>:</h4>
<p>just monomorphize <code>arg_tys[1]</code> or whatever type you wanna call <code>simd_size</code> on</p>



<a name="172682374"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682374" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682374">(Aug 07 2019 at 14:26)</a>:</h4>
<p>I think a layout is only computed for monomorphized types</p>



<a name="172682379"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682379" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682379">(Aug 07 2019 at 14:26)</a>:</h4>
<p>yea, but you should not touch it I believe</p>



<a name="172682385"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682385" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682385">(Aug 07 2019 at 14:26)</a>:</h4>
<p>yes, but your type is not monomorphic</p>



<a name="172682395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682395">(Aug 07 2019 at 14:26)</a>:</h4>
<p>I have to touch it, because currently <code>[T; N]</code> isn't supported in <code>repr(simd)</code> types, only tuple structs are</p>



<a name="172682406"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682406" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682406">(Aug 07 2019 at 14:27)</a>:</h4>
<p>and the number of elements of tuple structs is always known, even if they are generic</p>



<a name="172682426"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682426" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682426">(Aug 07 2019 at 14:27)</a>:</h4>
<p>oh, you're doing two things</p>



<a name="172682428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682428">(Aug 07 2019 at 14:27)</a>:</h4>
<p>so I at least need to patternmatch on elements that are arrays there, and do something about them</p>



<a name="172682432"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682432" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682432">(Aug 07 2019 at 14:27)</a>:</h4>
<p>go ahead then</p>



<a name="172682434"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682434" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682434">(Aug 07 2019 at 14:27)</a>:</h4>
<p>ah yes</p>



<a name="172682449"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682449" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682449">(Aug 07 2019 at 14:27)</a>:</h4>
<p>but my changes should not have an effect on anything you do</p>



<a name="172682453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682453">(Aug 07 2019 at 14:27)</a>:</h4>
<p>so <code>repr(simd) struct X([f32; 4]);</code> is not supported yet either (my branch does)</p>



<a name="172682515"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682515" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682515">(Aug 07 2019 at 14:28)</a>:</h4>
<p>you'll still hit the same thing</p>



<a name="172682521"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682521" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682521">(Aug 07 2019 at 14:28)</a>:</h4>
<p>but I wanted to try to make sure that <code>#[repr(simd)] struct X&lt;const N: usize&gt;([f32; N])</code> works as well</p>



<a name="172682528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682528">(Aug 07 2019 at 14:28)</a>:</h4>
<p>yes, I was hitting the same thing with a concrete <code>4</code></p>



<a name="172682543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682543">(Aug 07 2019 at 14:28)</a>:</h4>
<p>do you have a backtrace available?</p>



<a name="172682547"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682547" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682547">(Aug 07 2019 at 14:28)</a>:</h4>
<p>hmm</p>



<a name="172682551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682551">(Aug 07 2019 at 14:28)</a>:</h4>
<p>I think you forgot a monomorphize call somewhere</p>



<a name="172682558"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682558" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682558">(Aug 07 2019 at 14:28)</a>:</h4>
<p>let me scroll, like a couple of days</p>



<a name="172682565"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682565" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682565">(Aug 07 2019 at 14:28)</a>:</h4>
<p>don't try to get concrete <code>4</code> working</p>



<a name="172682579"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682579" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682579">(Aug 07 2019 at 14:29)</a>:</h4>
<p>just go directly for const generics</p>



<a name="172682604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682604">(Aug 07 2019 at 14:29)</a>:</h4>
<p>I worked around this by doing something else</p>



<a name="172682614"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682614" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682614">(Aug 07 2019 at 14:29)</a>:</h4>
<p>I think, by removing the <code>simd_size</code> call</p>



<a name="172682636"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682636" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682636">(Aug 07 2019 at 14:29)</a>:</h4>
<p>there was a stale check in rustc_typeck that checked that N was a power of two</p>



<a name="172682693"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682693" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682693">(Aug 07 2019 at 14:30)</a>:</h4>
<p>I don't think we can check that there if we want to support const generics</p>



<a name="172682971"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682971" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682971">(Aug 07 2019 at 14:33)</a>:</h4>
<p>you can check it after monomorphization, but that's a bit bad</p>



<a name="172682986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172682986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172682986">(Aug 07 2019 at 14:33)</a>:</h4>
<p>you can also make the generic arg be the power of two that should be used :P</p>



<a name="172683042"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172683042" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172683042">(Aug 07 2019 at 14:34)</a>:</h4>
<p>so <code>1</code> for <code>2</code> and <code>2</code> for <code>4</code> and <code>3</code> for <code>8</code> and so on</p>



<a name="172683066"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172683066" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172683066">(Aug 07 2019 at 14:34)</a>:</h4>
<p><code>const N: NonZeroUsize</code> :D</p>



<a name="172683122"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172683122" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172683122">(Aug 07 2019 at 14:35)</a>:</h4>
<p>we have an upper bound on the largest power of two supported problably</p>



<a name="172683193"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172683193" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172683193">(Aug 07 2019 at 14:36)</a>:</h4>
<p>ok i rebased, and migrated unwrap_usize to eval_usize</p>



<a name="172683197"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172683197" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172683197">(Aug 07 2019 at 14:36)</a>:</h4>
<p>but i'm now missing a ParamEnv</p>



<a name="172683260"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172683260" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172683260">(Aug 07 2019 at 14:37)</a>:</h4>
<p>either way, for the time being, we just support all Ns</p>



<a name="172683278"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172683278" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172683278">(Aug 07 2019 at 14:37)</a>:</h4>
<p>it will be up to libcore to constraint things in meaningful ways</p>



<a name="172683391"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172683391" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172683391">(Aug 07 2019 at 14:39)</a>:</h4>
<p>pass down the param_env as an argument of <code>simd_size</code></p>



<a name="172683411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172683411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172683411">(Aug 07 2019 at 14:39)</a>:</h4>
<p>in llvm you can just do <code>ParamEnv::reveal_all()</code></p>



<a name="172683419"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172683419" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172683419">(Aug 07 2019 at 14:39)</a>:</h4>
<p>everywhere else you should take the <code>ParamEnv</code> from the surroundings</p>



<a name="172684296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172684296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172684296">(Aug 07 2019 at 14:50)</a>:</h4>
<p><code>TyS</code> doesn't have a <code>ParamEnv</code></p>



<a name="172684316"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172684316" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172684316">(Aug 07 2019 at 14:50)</a>:</h4>
<p>i ended up using ty::ParamEnv::empty()</p>



<a name="172687199"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172687199" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172687199">(Aug 07 2019 at 15:22)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> it... just works...</p>



<a name="172687206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172687206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172687206">(Aug 07 2019 at 15:23)</a>:</h4>
<p>is this a good thing ?</p>



<a name="172689051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172689051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172689051">(Aug 07 2019 at 15:42)</a>:</h4>
<p>uh</p>



<a name="172690541"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172690541" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172690541">(Aug 07 2019 at 15:58)</a>:</h4>
<p>ok only the basic tests work, adding more complex tests things start breaking</p>



<a name="172692695"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172692695" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172692695">(Aug 07 2019 at 16:25)</a>:</h4>
<p>ok so eval_usize appears to be a bad idea</p>



<a name="172692716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172692716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172692716">(Aug 07 2019 at 16:25)</a>:</h4>
<p>for some reason, the layout of a <code>struct S&lt;const N: usize&gt;([f32; N]);</code> is required before monomorphization</p>



<a name="172692717"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172692717" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172692717">(Aug 07 2019 at 16:25)</a>:</h4>
<p>e.g.</p>



<a name="172692731"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172692731" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172692731">(Aug 07 2019 at 16:25)</a>:</h4>
<p>a simple lib crate that exposes a <code>pub S</code> fails</p>



<a name="172693742"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172693742" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172693742">(Aug 07 2019 at 16:39)</a>:</h4>
<p>Told you ^^</p>



<a name="172693775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172693775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172693775">(Aug 07 2019 at 16:39)</a>:</h4>
<p>Can you backtrace the place where it's invoked before llvm?</p>



<a name="172694152"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172694152" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172694152">(Aug 07 2019 at 16:45)</a>:</h4>
<p>i'm kind of coming forward with debugging</p>



<a name="172694219"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172694219" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172694219">(Aug 07 2019 at 16:46)</a>:</h4>
<p>i am going to make the simd_size function of sty take a ParamEnv environment</p>



<a name="172694223"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172694223" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172694223">(Aug 07 2019 at 16:46)</a>:</h4>
<p>and then do what is done for arrays in Layout</p>



<a name="172694270"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172694270" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172694270">(Aug 07 2019 at 16:46)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="k">if</span><span class="w"> </span><span class="n">count</span><span class="p">.</span><span class="n">has_projections</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">count</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">tcx</span><span class="p">.</span><span class="n">normalize_erasing_regions</span><span class="p">(</span><span class="n">param_env</span><span class="p">,</span><span class="w"> </span><span class="n">count</span><span class="p">);</span><span class="w"></span>
<span class="w">     </span><span class="k">if</span><span class="w"> </span><span class="n">count</span><span class="p">.</span><span class="n">has_projections</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">         </span><span class="k">return</span><span class="w"> </span><span class="nb">Err</span><span class="p">(</span><span class="n">LayoutError</span>::<span class="n">Unknown</span><span class="p">(</span><span class="n">ty</span><span class="p">));</span><span class="w"></span>
<span class="w">     </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="kd">let</span><span class="w"> </span><span class="n">count</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">count</span><span class="p">.</span><span class="n">try_eval_usize</span><span class="p">(</span><span class="n">tcx</span><span class="p">,</span><span class="w"> </span><span class="n">param_env</span><span class="p">).</span><span class="n">ok_or</span><span class="p">(</span><span class="n">LayoutError</span>::<span class="n">Unknown</span><span class="p">(</span><span class="n">ty</span><span class="p">))</span><span class="o">?</span><span class="p">;</span><span class="w"></span>
</pre></div>



<a name="172694391"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172694391" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172694391">(Aug 07 2019 at 16:49)</a>:</h4>
<p>Yea that seems reasonable</p>



<a name="172756779"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172756779" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172756779">(Aug 08 2019 at 11:33)</a>:</h4>
<p>so i'm stuck now</p>



<a name="172756785"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172756785" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172756785">(Aug 08 2019 at 11:33)</a>:</h4>
<p>i solved a couple of issues</p>



<a name="172756788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172756788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172756788">(Aug 08 2019 at 11:33)</a>:</h4>
<p>but I'm getting incorrect code generation in a couple of places</p>



<a name="172756865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172756865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172756865">(Aug 08 2019 at 11:34)</a>:</h4>
<p>the llvm-ir that i'm seeing is completely wrong, i'm gonna have to learn how to read mir</p>



<a name="172756964"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172756964" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172756964">(Aug 08 2019 at 11:36)</a>:</h4>
<p>that's the mir for the following program(<a href="https://gist.github.com/gnzlbg/479ba3ee6a563af17e0d517de21e241b" target="_blank" title="https://gist.github.com/gnzlbg/479ba3ee6a563af17e0d517de21e241b">https://gist.github.com/gnzlbg/479ba3ee6a563af17e0d517de21e241b</a>): </p>
<div class="codehilite"><pre><span></span><span class="c1">// run-pass</span>
<span class="cp">#![allow(non_camel_case_types, incomplete_features)]</span><span class="w"></span>
<span class="cp">#![feature(repr_simd, platform_intrinsics, const_generics)]</span><span class="w"></span>

<span class="k">use</span><span class="w"> </span><span class="n">std</span>::<span class="n">ops</span><span class="p">;</span><span class="w"></span>

<span class="cp">#[repr(simd)]</span><span class="w"></span>
<span class="cp">#[derive(Copy, Clone)]</span><span class="w"></span>
<span class="k">struct</span> <span class="nc">S</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="p">([</span><span class="kt">f32</span><span class="p">;</span><span class="w"> </span><span class="n">N</span><span class="p">]);</span><span class="w"></span>


<span class="k">extern</span><span class="w"> </span><span class="s">&quot;platform-intrinsic&quot;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">simd_add</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">(</span><span class="n">x</span>: <span class="nc">T</span><span class="p">,</span><span class="w"> </span><span class="n">y</span>: <span class="nc">T</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">T</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">simd_extract</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">E</span><span class="o">&gt;</span><span class="p">(</span><span class="n">v</span>: <span class="nc">T</span><span class="p">,</span><span class="w"> </span><span class="n">idx</span>: <span class="kt">u32</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">E</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">add</span><span class="o">&lt;</span><span class="n">T</span>: <span class="nc">ops</span>::<span class="n">Add</span><span class="o">&lt;</span><span class="n">Output</span><span class="o">=</span><span class="n">T</span><span class="o">&gt;&gt;</span><span class="p">(</span><span class="n">lhs</span>: <span class="nc">T</span><span class="p">,</span><span class="w"> </span><span class="n">rhs</span>: <span class="nc">T</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">T</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">lhs</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">rhs</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="w"> </span><span class="n">ops</span>::<span class="n">Add</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">S</span><span class="o">&lt;</span><span class="mi">4</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">Output</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Self</span><span class="p">;</span><span class="w"></span>

<span class="w">    </span><span class="k">fn</span> <span class="nf">add</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">rhs</span>: <span class="nc">Self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Self</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="n">simd_add</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">rhs</span><span class="p">)}</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>


<span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">lr2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">S</span>::<span class="o">&lt;</span><span class="mi">4</span><span class="o">&gt;</span><span class="p">([</span><span class="mf">1.0</span><span class="k">f32</span><span class="p">,</span><span class="w"> </span><span class="mf">2.0</span><span class="k">f32</span><span class="p">,</span><span class="w"> </span><span class="mf">3.0</span><span class="k">f32</span><span class="p">,</span><span class="w"> </span><span class="mf">4.0</span><span class="k">f32</span><span class="p">]);</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">add</span><span class="p">(</span><span class="n">lr2</span><span class="p">,</span><span class="w"> </span><span class="n">lr2</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">x</span>: <span class="kt">f32</span> <span class="o">=</span><span class="w"> </span><span class="n">simd_extract</span><span class="p">(</span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">y</span>: <span class="kt">f32</span> <span class="o">=</span><span class="w"> </span><span class="n">simd_extract</span><span class="p">(</span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="n">assert_eq</span><span class="o">!</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="w"> </span><span class="mf">2.0</span><span class="k">f32</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="n">assert_eq</span><span class="o">!</span><span class="p">(</span><span class="n">y</span><span class="p">,</span><span class="w"> </span><span class="mf">4.0</span><span class="k">f32</span><span class="p">);</span><span class="w"></span>
<span class="p">}}</span><span class="w"></span>
</pre></div>



<a name="172757312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172757312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172757312">(Aug 08 2019 at 11:43)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> can it be that this is being evaluated at compile-time ?</p>



<a name="172757316"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172757316" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172757316">(Aug 08 2019 at 11:43)</a>:</h4>
<p>and constant evaluation is doing something wrong ?</p>



<a name="172757881"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172757881" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172757881">(Aug 08 2019 at 11:55)</a>:</h4>
<p>For this:</p>
<div class="codehilite"><pre><span></span><span class="cp">#[inline(never)]</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">add_pair</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="p">(</span><span class="kt">f32</span><span class="p">,</span><span class="w"> </span><span class="kt">f32</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">lr2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">S</span>::<span class="o">&lt;</span><span class="mi">4</span><span class="o">&gt;</span><span class="p">([</span><span class="mf">1.0</span><span class="k">f32</span><span class="p">,</span><span class="w"> </span><span class="mf">2.0</span><span class="k">f32</span><span class="p">,</span><span class="w"> </span><span class="mf">3.0</span><span class="k">f32</span><span class="p">,</span><span class="w"> </span><span class="mf">4.0</span><span class="k">f32</span><span class="p">]);</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">simd_add</span><span class="p">(</span><span class="n">lr2</span><span class="p">,</span><span class="w"> </span><span class="n">lr2</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">x</span>: <span class="kt">f32</span> <span class="o">=</span><span class="w"> </span><span class="n">simd_extract</span><span class="p">(</span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">y</span>: <span class="kt">f32</span> <span class="o">=</span><span class="w"> </span><span class="n">simd_extract</span><span class="p">(</span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="w"> </span><span class="n">y</span><span class="p">)</span><span class="w"></span>
<span class="p">}}</span><span class="w"></span>
</pre></div>


<p>I get the following MIR:</p>
<div class="codehilite"><pre><span></span>fn  add_pair() -&gt; (f32, f32) {
    let mut _0: (f32, f32);              // return place in scope 0 at /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:18:22: 18:32
    let mut _2: [f32; 4];                // in scope 0 at /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:19:22: 19:54
    let mut _4: S&lt;4usize&gt;;               // in scope 0 at /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:20:22: 20:25
    let mut _5: S&lt;4usize&gt;;               // in scope 0 at /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:20:27: 20:30
    let mut _7: S&lt;4usize&gt;;               // in scope 0 at /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:21:31: 21:32
    let mut _9: S&lt;4usize&gt;;               // in scope 0 at /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:22:31: 22:32
    let mut _10: f32;                    // in scope 0 at /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:23:6: 23:7
    let mut _11: f32;                    // in scope 0 at /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:23:9: 23:10
    scope 1 {
        let _1: S&lt;4usize&gt;;               // &quot;lr2&quot; in scope 1 at /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:19:9: 19:12
        scope 2 {
            let _3: S&lt;4usize&gt;;           // &quot;a&quot; in scope 2 at /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:20:9: 20:10
            scope 3 {
                let _6: f32 as UserTypeProjection { base: UserType(1), projs: [] }; // &quot;x&quot; in scope 3 at /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:21:9: 21:10
                scope 4 {
                    let _8: f32 as UserTypeProjection { base: UserType(3), projs: [] }; // &quot;y&quot; in scope 4 at /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:22:9: 22:10
                    scope 5 {
                    }
                }
            }
        }
    }

    bb0: {
        StorageLive(_1);                 // bb0[0]: scope 1 at /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:19:9: 19:12
        StorageLive(_2);                 // bb0[1]: scope 1 at /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:19:22: 19:54
        _2 = [const 1f32, const 2f32, const 3f32, const 4f32]; // bb0[2]: scope 1 at /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:19:22: 19:54
                                         // ty::Const
                                         // + ty: f32
                                         // + val: Scalar(0x3f800000)
                                         // mir::Constant
                                         // + span: /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:19:23: 19:29
                                         // + ty: f32
                                         // + literal: Const { ty: f32, val: Scalar(0x3f800000) }
                                         // ty::Const
                                         // + ty: f32
                                         // + val: Scalar(0x40000000)
                                         // mir::Constant
                                         // + span: /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:19:31: 19:37
                                         // + ty: f32
                                         // + literal: Const { ty: f32, val: Scalar(0x40000000) }
                                         // ty::Const
                                         // + ty: f32
                                         // + val: Scalar(0x40400000)
                                         // mir::Constant
                                         // + span: /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:19:39: 19:45
                                         // + ty: f32
                                         // + literal: Const { ty: f32, val: Scalar(0x40400000) }
                                         // ty::Const
                                         // + ty: f32
                                         // + val: Scalar(0x40800000)
                                         // mir::Constant
                                         // + span: /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:19:47: 19:53
                                         // + ty: f32
                                         // + literal: Const { ty: f32, val: Scalar(0x40800000) }
        (_1.0: [f32; 4]) = move _2;      // bb0[3]: scope 1 at /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:19:15: 19:55
        StorageDead(_2);                 // bb0[4]: scope 1 at /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:19:54: 19:55
        StorageLive(_3);                 // bb0[5]: scope 2 at /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:20:9: 20:10
        StorageLive(_4);                 // bb0[6]: scope 2 at /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:20:22: 20:25
        _4 = _1;                         // bb0[7]: scope 2 at /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:20:22: 20:25
        StorageLive(_5);                 // bb0[8]: scope 2 at /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:20:27: 20:30
        _5 = _1;                         // bb0[9]: scope 2 at /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:20:27: 20:30
        _3 = const simd_add::&lt;S&lt;4usize&gt;&gt;(move _4, move _5) -&gt; bb1; // bb0[10]: scope 2 at /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:20:13: 20:31
                                         // ty::Const
                                         // + ty: unsafe extern &quot;platform-intrinsic&quot; fn(S&lt;4usize&gt;, S&lt;4usize&gt;) -&gt; S&lt;4usize&gt; {simd_add::&lt;S&lt;4usize&gt;&gt;}
                                         // + val: Scalar(&lt;ZST&gt;)
                                         // mir::Constant
                                         // + span: /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:20:13: 20:21
                                         // + ty: unsafe extern &quot;platform-intrinsic&quot; fn(S&lt;4usize&gt;, S&lt;4usize&gt;) -&gt; S&lt;4usize&gt; {simd_add::&lt;S&lt;4usize&gt;&gt;}
                                         // + literal: Const { ty: unsafe extern &quot;platform-intrinsic&quot; fn(S&lt;4usize&gt;, S&lt;4usize&gt;) -&gt; S&lt;4usize&gt; {simd_add::&lt;S&lt;4usize&gt;&gt;}, val: Scalar(&lt;ZST&gt;) }
    }

    bb1: {
        StorageDead(_5);                 // bb1[0]: scope 2 at /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:20:30: 20:31
        StorageDead(_4);                 // bb1[1]: scope 2 at /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:20:30: 20:31
        StorageLive(_6);                 // bb1[2]: scope 3 at /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:21:9: 21:10
        StorageLive(_7);                 // bb1[3]: scope 3 at /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:21:31: 21:32
        _7 = _3;                         // bb1[4]: scope 3 at /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:21:31: 21:32
        _6 = const simd_extract::&lt;S&lt;4usize&gt;, f32&gt;(move _7, const 0u32) -&gt; bb2; // bb1[5]: scope 3 at /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:21:18: 21:36
                                         // ty::Const
                                         // + ty: unsafe extern &quot;platform-intrinsic&quot; fn(S&lt;4usize&gt;, u32) -&gt; f32 {simd_extract::&lt;S&lt;4usize&gt;, f32&gt;}
                                         // + val: Scalar(&lt;ZST&gt;)
                                         // mir::Constant
                                         // + span: /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:21:18: 21:30
                                         // + ty: unsafe extern &quot;platform-intrinsic&quot; fn(S&lt;4usize&gt;, u32) -&gt; f32 {simd_extract::&lt;S&lt;4usize&gt;, f32&gt;}
                                         // + literal: Const { ty: unsafe extern &quot;platform-intrinsic&quot; fn(S&lt;4usize&gt;, u32) -&gt; f32 {simd_extract::&lt;S&lt;4usize&gt;, f32&gt;}, val: Scalar(&lt;ZST&gt;) }
                                         // ty::Const
                                         // + ty: u32
                                         // + val: Scalar(0x00000000)
                                         // mir::Constant
                                         // + span: /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:21:34: 21:35
                                         // + ty: u32
                                         // + literal: Const { ty: u32, val: Scalar(0x00000000) }
    }

    bb2: {
        StorageDead(_7);                 // bb2[0]: scope 3 at /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:21:35: 21:36
        StorageLive(_8);                 // bb2[1]: scope 4 at /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:22:9: 22:10
        StorageLive(_9);                 // bb2[2]: scope 4 at /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:22:31: 22:32
        _9 = _3;                         // bb2[3]: scope 4 at /Users/gnzlbg/projects/sideprojects/rust/src/test/ui/simd/simd-generics.rs:22:31: 22:32
        _8 = const simd_extract::&lt;S&lt;4usize&gt;, f32&gt;(move _9, const 1u32) -&gt; bb3; // bb2[4]: scope 4 a
</pre></div>



<a name="172757978"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172757978" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172757978">(Aug 08 2019 at 11:57)</a>:</h4>
<p>What's this <code>const simd_add::&lt;S&lt;4usize&gt;&gt;(move _4, move _5)</code> doing ? Is this evaluating <code>simd_add</code> at compile-time ?</p>



<a name="172758098"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172758098" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172758098">(Aug 08 2019 at 11:59)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="119009">@eddyb</span>  ^^^</p>



<a name="172758722"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172758722" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172758722">(Aug 08 2019 at 12:10)</a>:</h4>
<p>Smaller example, the LLVM-IR generated is broken: <a href="https://gcc.godbolt.org/z/3nuRpN" target="_blank" title="https://gcc.godbolt.org/z/3nuRpN">https://gcc.godbolt.org/z/3nuRpN</a></p>



<a name="172758725"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172758725" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172758725">(Aug 08 2019 at 12:10)</a>:</h4>
<blockquote>
<p>What's this <code>const simd_add::&lt;S&lt;4usize&gt;&gt;(move _4, move _5)</code> doing ? Is this evaluating <code>simd_add</code> at compile-time ?</p>
</blockquote>
<p>I'm pretty sure that just means that function call is to a <code>ConstVal </code>which is a function pointer to <code>simd_add</code>. It doesn't mean that the function call is being evaluated at compile time.</p>



<a name="172758865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172758865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172758865">(Aug 08 2019 at 12:13)</a>:</h4>
<p>found the issue, the memcpy in the last example is incorrect</p>



<a name="172758918"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172758918" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172758918">(Aug 08 2019 at 12:14)</a>:</h4>
<p>for some reason, when copying the [f32; 4] array into the &lt;4 x f32&gt; vector, we call <code>memcpy</code> with a length of 4 bytes</p>



<a name="172758935"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172758935" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172758935">(Aug 08 2019 at 12:14)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="k">call</span> <span class="k">void</span> <span class="vg">@llvm.memcpy.p0i8.p0i8.i64</span><span class="p">(</span><span class="k">i8</span><span class="p">*</span> <span class="k">align</span> <span class="m">16</span> <span class="nv nv-Anonymous">%5</span><span class="p">,</span> <span class="k">i8</span><span class="p">*</span> <span class="k">align</span> <span class="m">4</span> <span class="nv nv-Anonymous">%6</span><span class="p">,</span> <span class="k">i64</span> <span class="m">4</span><span class="p">,</span> <span class="k">i1</span> <span class="k">false</span><span class="p">)</span>
</pre></div>



<a name="172758950"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172758950" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172758950">(Aug 08 2019 at 12:14)</a>:</h4>
<p>we should call it with a length of <code>4 * sizeof(f32) == 16</code> bytes</p>



<a name="172758979"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172758979" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172758979">(Aug 08 2019 at 12:15)</a>:</h4>
<p>that fixes the bug, now the question is, where is this coming from</p>



<a name="172762930"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172762930" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172762930">(Aug 08 2019 at 13:12)</a>:</h4>
<p>there's no <code>memcpy</code> in the MIR, is it being generated by the simd intrinsics?</p>



<a name="172764177"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172764177" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172764177">(Aug 08 2019 at 13:27)</a>:</h4>
<p>@oli  no, it is maybe generated by <code>move</code> in the mir ?</p>



<a name="172764207"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172764207" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172764207">(Aug 08 2019 at 13:27)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">build_array</span><span class="p">(</span><span class="n">x</span>: <span class="p">[</span><span class="kt">f32</span><span class="p">;</span><span class="w"> </span><span class="mi">4</span><span class="p">])</span><span class="w"> </span>-&gt; <span class="nc">S</span><span class="o">&lt;</span><span class="mi">4</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w">  </span><span class="n">S</span>::<span class="o">&lt;</span><span class="mi">4</span><span class="o">&gt;</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</pre></div>



<a name="172764231"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172764231" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172764231">(Aug 08 2019 at 13:28)</a>:</h4>
<p>that reproduces the issue</p>



<a name="172764288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172764288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172764288">(Aug 08 2019 at 13:28)</a>:</h4>
<p>the layout of a simd type is not queried anywhere</p>



<a name="172764324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172764324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172764324">(Aug 08 2019 at 13:28)</a>:</h4>
<p>when generating this incorrect LLVM-IR for it:</p>
<div class="codehilite"><pre><span></span><span class="k">define</span> <span class="k">void</span> <span class="vg">@build_array</span><span class="p">(&lt;</span><span class="m">4</span> <span class="k">x</span> <span class="k">float</span><span class="p">&gt;*</span> <span class="k">noalias</span> <span class="k">nocapture</span> <span class="k">sret</span> <span class="k">dereferenceable</span><span class="p">(</span><span class="m">16</span><span class="p">),</span> <span class="p">[</span><span class="m">4</span> <span class="k">x</span> <span class="k">float</span><span class="p">]*</span> <span class="k">noalias</span> <span class="k">nocapture</span> <span class="k">dereferenceable</span><span class="p">(</span><span class="m">16</span><span class="p">)</span> <span class="nv">%x</span><span class="p">)</span> <span class="k">unnamed_addr</span> <span class="vg">#0</span> <span class="p">{</span>
<span class="nl">start:</span>
  <span class="nv">%_2</span> <span class="p">=</span> <span class="k">alloca</span> <span class="p">[</span><span class="m">4</span> <span class="k">x</span> <span class="k">float</span><span class="p">],</span> <span class="k">align</span> <span class="m">4</span>
  <span class="nv nv-Anonymous">%1</span> <span class="p">=</span> <span class="k">bitcast</span> <span class="p">[</span><span class="m">4</span> <span class="k">x</span> <span class="k">float</span><span class="p">]*</span> <span class="nv">%_2</span> <span class="k">to</span> <span class="k">i8</span><span class="p">*</span>
  <span class="k">call</span> <span class="k">void</span> <span class="vg">@llvm.lifetime.start.p0i8</span><span class="p">(</span><span class="k">i64</span> <span class="m">16</span><span class="p">,</span> <span class="k">i8</span><span class="p">*</span> <span class="nv nv-Anonymous">%1</span><span class="p">)</span>
  <span class="nv nv-Anonymous">%2</span> <span class="p">=</span> <span class="k">bitcast</span> <span class="p">[</span><span class="m">4</span> <span class="k">x</span> <span class="k">float</span><span class="p">]*</span> <span class="nv">%_2</span> <span class="k">to</span> <span class="k">i8</span><span class="p">*</span>
  <span class="nv nv-Anonymous">%3</span> <span class="p">=</span> <span class="k">bitcast</span> <span class="p">[</span><span class="m">4</span> <span class="k">x</span> <span class="k">float</span><span class="p">]*</span> <span class="nv">%x</span> <span class="k">to</span> <span class="k">i8</span><span class="p">*</span>
  <span class="k">call</span> <span class="k">void</span> <span class="vg">@llvm.memcpy.p0i8.p0i8.i64</span><span class="p">(</span><span class="k">i8</span><span class="p">*</span> <span class="k">align</span> <span class="m">4</span> <span class="nv nv-Anonymous">%2</span><span class="p">,</span> <span class="k">i8</span><span class="p">*</span> <span class="k">align</span> <span class="m">4</span> <span class="nv nv-Anonymous">%3</span><span class="p">,</span> <span class="k">i64</span> <span class="m">16</span><span class="p">,</span> <span class="k">i1</span> <span class="k">false</span><span class="p">)</span>
  <span class="nv nv-Anonymous">%4</span> <span class="p">=</span> <span class="k">bitcast</span> <span class="p">&lt;</span><span class="m">4</span> <span class="k">x</span> <span class="k">float</span><span class="p">&gt;*</span> <span class="nv nv-Anonymous">%0</span> <span class="k">to</span> <span class="k">float</span><span class="p">*</span>
  <span class="nv nv-Anonymous">%5</span> <span class="p">=</span> <span class="k">bitcast</span> <span class="k">float</span><span class="p">*</span> <span class="nv nv-Anonymous">%4</span> <span class="k">to</span> <span class="k">i8</span><span class="p">*</span>
  <span class="nv nv-Anonymous">%6</span> <span class="p">=</span> <span class="k">bitcast</span> <span class="p">[</span><span class="m">4</span> <span class="k">x</span> <span class="k">float</span><span class="p">]*</span> <span class="nv">%_2</span> <span class="k">to</span> <span class="k">i8</span><span class="p">*</span>
  <span class="k">call</span> <span class="k">void</span> <span class="vg">@llvm.memcpy.p0i8.p0i8.i64</span><span class="p">(</span><span class="k">i8</span><span class="p">*</span> <span class="k">align</span> <span class="m">16</span> <span class="nv nv-Anonymous">%5</span><span class="p">,</span> <span class="k">i8</span><span class="p">*</span> <span class="k">align</span> <span class="m">4</span> <span class="nv nv-Anonymous">%6</span><span class="p">,</span> <span class="k">i64</span> <span class="m">4</span><span class="p">,</span> <span class="k">i1</span> <span class="k">false</span><span class="p">)</span>
  <span class="nv nv-Anonymous">%7</span> <span class="p">=</span> <span class="k">bitcast</span> <span class="p">[</span><span class="m">4</span> <span class="k">x</span> <span class="k">float</span><span class="p">]*</span> <span class="nv">%_2</span> <span class="k">to</span> <span class="k">i8</span><span class="p">*</span>
  <span class="k">call</span> <span class="k">void</span> <span class="vg">@llvm.lifetime.end.p0i8</span><span class="p">(</span><span class="k">i64</span> <span class="m">16</span><span class="p">,</span> <span class="k">i8</span><span class="p">*</span> <span class="nv nv-Anonymous">%7</span><span class="p">)</span>
  <span class="k">ret</span> <span class="k">void</span>
<span class="p">}</span>
</pre></div>



<a name="172764370"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172764370" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172764370">(Aug 08 2019 at 13:29)</a>:</h4>
<p>(note that the second memcpy only copies 4 bytes into the vector, for whatever reason</p>



<a name="172764713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172764713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172764713">(Aug 08 2019 at 13:32)</a>:</h4>
<p>the mir i get is</p>
<div class="codehilite"><pre><span></span>fn  build_array(_1: [f32; 4]) -&gt; S&lt;4usize&gt; {
    let mut _0: S&lt;4usize&gt;;               // return place in scope 0 at /Users/gnzlbg/projects/sideprojects/rust/src/test/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs:14:36: 14:40
    let mut _2: [f32; 4];                // in scope 0 at /Users/gnzlbg/projects/sideprojects/rust/src/test/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs:16:12: 16:13

    bb0: {
        StorageLive(_2);                 // bb0[0]: scope 0 at /Users/gnzlbg/projects/sideprojects/rust/src/test/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs:16:12: 16:13
        _2 = _1;                         // bb0[1]: scope 0 at /Users/gnzlbg/projects/sideprojects/rust/src/test/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs:16:12: 16:13
        (_0.0: [f32; 4]) = move _2;      // bb0[2]: scope 0 at /Users/gnzlbg/projects/sideprojects/rust/src/test/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs:16:5: 16:14
        StorageDead(_2);                 // bb0[3]: scope 0 at /Users/gnzlbg/projects/sideprojects/rust/src/test/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs:16:13: 16:14
        return;                          // bb0[4]: scope 0 at /Users/gnzlbg/projects/sideprojects/rust/src/test/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs:17:2: 17:2
    }
}
</pre></div>



<a name="172764738"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172764738" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172764738">(Aug 08 2019 at 13:32)</a>:</h4>
<p>So <code>(_0.0: [f32; 4]) = move _2; </code> is what I'd say is geenrating the memcpy</p>



<a name="172765000"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172765000" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172765000">(Aug 08 2019 at 13:35)</a>:</h4>
<p>What I don't understand is why the layout of S&lt;4usize&gt; is not computed anywhere</p>



<a name="172765080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172765080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172765080">(Aug 08 2019 at 13:36)</a>:</h4>
<p>I'd suppose that to lower that to LLVM one must compute the layout of <code>S</code></p>



<a name="172765217"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172765217" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172765217">(Aug 08 2019 at 13:38)</a>:</h4>
<p>how are you checking that it's not being computed?</p>



<a name="172765429"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172765429" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172765429">(Aug 08 2019 at 13:41)</a>:</h4>
<p>I have an <code>eprintln!</code> in the Layout pattern for it</p>



<a name="172765445"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172765445" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172765445">(Aug 08 2019 at 13:42)</a>:</h4>
<p>when building other code it shows, when building this particular test it does not</p>



<a name="172765512"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172765512" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172765512">(Aug 08 2019 at 13:42)</a>:</h4>
<p>maybe instead of fetching the layout, some code is calling <code>simd_size</code> and <code>simd_type</code> and doing some manual layout computation for this ?</p>



<a name="172765531"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172765531" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172765531">(Aug 08 2019 at 13:43)</a>:</h4>
<p>I'm trying to figure out where the memcpys are generated so that i can try to trace things back</p>



<a name="172765546"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172765546" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172765546">(Aug 08 2019 at 13:43)</a>:</h4>
<p>but grepping for "move" isn't super helpful</p>



<a name="172765557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172765557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172765557">(Aug 08 2019 at 13:43)</a>:</h4>
<p>well... <code>Operand::Move</code></p>



<a name="172779761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172779761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172779761">(Aug 08 2019 at 16:24)</a>:</h4>
<p>ok, so the layout was called</p>



<a name="172779780"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172779780" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172779780">(Aug 08 2019 at 16:24)</a>:</h4>
<p>compiletest without --verbose swallows eprintln statements from rustc, and logs</p>



<a name="172779831"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172779831" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172779831">(Aug 08 2019 at 16:25)</a>:</h4>
<p>the layout returned is correct</p>



<a name="172779891"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172779891" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172779891">(Aug 08 2019 at 16:26)</a>:</h4>
<p>I have no idea where the incorrect memcpy size might be coming from, or how to debug it, <code>Operand::Move</code> is quite abstract</p>



<a name="172780224"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172780224" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172780224">(Aug 08 2019 at 16:30)</a>:</h4>
<p>the code in rustc_codegen_ssa does the obvious thing for Operand::Move</p>



<a name="172786465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172786465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172786465">(Aug 08 2019 at 17:46)</a>:</h4>
<p>have you checked whether <code>std::mem::type_size</code> still returns the right thing for your type?</p>



<a name="172790175"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172790175" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172790175">(Aug 08 2019 at 18:25)</a>:</h4>
<p>checking that right now</p>



<a name="172790194"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/repr%28simd%29%20struct%3Cconst%20N%3A%20usize%3E%28%5BT%3B%20N%5D%29/near/172790194" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/repr(simd).20struct.3Cconst.20N.3A.20usize.3E(.5BT.3B.20N.5D).html#172790194">(Aug 08 2019 at 18:25)</a>:</h4>
<p>i published the branch here: <a href="https://github.com/gnzlbg/rust/tree/array_simd" target="_blank" title="https://github.com/gnzlbg/rust/tree/array_simd">https://github.com/gnzlbg/rust/tree/array_simd</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>